<?php
namespace App\Http\Controllers\Api\v1;

use App\Http\Controllers\Api\BaseController;
use App\Http\Requests\LinkRequest;
use App\Http\Resources\Link;
use App\Http\Resources\LinkCollection;
use App\Link as LinkModel;
use App\Repositories\LinkRepository;
use App\Traits\BaseApiFunc;
use Auth;
use Illuminate\Database\Eloquent\Collection;

class LinkController extends BaseController {

	use BaseApiFunc;

	protected $model, $page_size;

	public function __construct(LinkRepository $link) {
		parent::__construct();

		$this->model = $link;
		$this->page_size = config('blog.admin_page.common_page');
	}

	public function store(LinkRequest $request) {
		$this->model->store(array_merge(['user_id' => Auth::user()->id], $request->all()));
		return $this->response->withNoContent();
	}

	protected function getResourceCollection(Collection $collection) {
		return new LinkCollection($collection);
	}

	protected function getResource(LinkModel $collection) {
		return new Link($collection);
	}
}
